package org.example.xx2.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailService {
    
    @Autowired
    private JavaMailSender mailSender;
    
    public void sendVerificationCode(String to, String code) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setSubject("密码找回验证码");
        message.setText("您的验证码是：" + code + "，有效期5分钟，请勿泄露给他人。");
        
        mailSender.send(message);
    }
    
    public void sendPasswordResetSuccess(String to, String username) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setSubject("密码重置成功");
        message.setText("尊敬的" + username + "，您的密码已成功重置，请使用新密码登录。");
        
        mailSender.send(message);
    }
} 